package com.wang;

import com.wang.pojo.Adynasty;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

import java.util.Arrays;
import java.util.Map;

/**
 * SpringBoot的核心启动类
 * @author Zjx
 */
@SpringBootApplication
public class CoreApplication {
    private static Logger log = LogManager.getLogger();

    public static void main(String[] args) {
        /**
         * 启动SpringBoot的程序
         */
        ConfigurableApplicationContext ac = SpringApplication.run(CoreApplication.class, args);
        /* 获取环境 */
        ConfigurableEnvironment env = ac.getEnvironment();
        log.info("==:{}", env);
        /* Java的自带属性; System.getProperties() */
        Map<String, Object> pro = env.getSystemProperties();
        log.info("=pro:{}==", pro);
        /* 环境变量 */
        Map<String, Object> systemEvn = env.getSystemEnvironment();
        log.info("=systemEvn:{}==", systemEvn);

        /* 获取对象 */
//        Aking king = ac.getBean("aking", Aking.class);
//        log.info("皇上:{},hashcode:{}", king, king.hashCode());

        /* 获取对象 */
//        Aking king01 = ac.getBean("king01", Aking.class);
//        log.info("皇上01:{},hashcode:{}", king01, king01.hashCode());

        /* 获取对象 */
        Adynasty dyna01 = ac.getBean("adynasty", Adynasty.class);
        log.info("朝代01:{},hashcode:{}", dyna01, dyna01.hashCode());
        log.info("===getHobbyArr:{},长度:{}==", Arrays.toString(dyna01.getHobbyArr()), dyna01.getHobbyArr().length);
        log.info("==getHobbyList:{},长度:{}===", dyna01.getHobbyList(), dyna01.getHobbyList().size());
        log.info("==getHobbySet:{},长度:{}===", dyna01.getHobbySet(), dyna01.getHobbySet().size());
        log.info("==getHobbyMap:{},长度:{}===", dyna01.getHobbyMap(), dyna01.getHobbyMap().size());

        log.info("==皇上:getKingArr{},长度:{}==", Arrays.toString(dyna01.getKingArr()), dyna01.getKingArr().length);
        log.info("==皇上:getKingList{},长度:{}==", dyna01.getKingList(), dyna01.getKingList().size());
        log.info("==皇上:getKingSet{},长度:{}==", dyna01.getKingSet(), dyna01.getKingSet().size());
        log.info("==皇上:getKingMap{},长度:{}==", dyna01.getKingMap(), dyna01.getKingMap().size());
        log.info("==皇上:getKingPro{},长度:{}==", dyna01.getKingPro(), dyna01.getKingPro().size());
    }
}